package jsyf.oa.web.equipmentAccount;


import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.equipmentAccount.EquipmentAccountFacade;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(value = "服务台帐接口", description = "服务台帐接口")
@Controller
@RequestMapping("/equipmentAccount")
public class EquipmentAccountController {
    @Resource
    private EquipmentAccountFacade equipmentAccountFacade;

    @RequestMapping(value = "/getDeviceList.json", method = RequestMethod.POST)
    public void getDeviceList(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = this.equipmentAccountFacade.getDeviceList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(result));
    }

    @RequestMapping(value = "/getDeviceById.json", method = RequestMethod.POST)
    public void getDeviceById(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject result = this.equipmentAccountFacade.getDeviceById(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(result));
    }

    @RequestMapping(value = "/save.json", method = RequestMethod.POST)
    public void save(HttpServletResponse response, @RequestBody String jsonData) {
        Boolean result = this.equipmentAccountFacade.save(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(result.toString()));
    }
}
